<table>
  <tr>
    <td id="leftpanel" valign="top">
        <div id="leftpaneldiv">
            <a href="javascript:void(0);" id="hidePanel"><img id="collapse" src="{$fvConfig->get('dir_web_root')}img/collapse.gif" width="15" height="15"></a>
            <div class="header" id="leftPanelHeader">Список страниц</div>
            <div id="leftpaneldata">
                <ul id="sortables">
                {section name=menuItem loop=$Sections}
                    {if $Sections[menuItem].parent_id && ($smarty.section.menuItem.index_prev != -1) && ($Sections[$smarty.section.menuItem.index_prev].parent_id == 0)}
                        <ul><li id="sortables_{$Sections[menuItem].id}">
                    {else}
                        <li id="sortables_{$Sections[menuItem].id}">
                    {/if}
                    <div style="float: right">
        				<A href="{$fvConfig->get('dir_web_root')}sections/?id={$Sections[menuItem].id}" onclick="go('{$fvConfig->get('dir_web_root')}sections/?id={$Sections[menuItem].id}'); return false;">
        					<img src="{$fvConfig->get('dir_web_root')}img/edit_icon.png" title="редактировать" width="16" height="16">
        				</a>
        				<a href="javascript: void(0);" onclick="if (confirm('Вы действительно желаете удалить раздел. Все дочерние разделы перенесутся в корень.')) go('{$fvConfig->get('dir_web_root')}sections/delete/?id={$Sections[menuItem].id}'); return false;">
        					<img src="{$fvConfig->get('dir_web_root')}img/delete_icon.png" title="удалить" width="16" height="16">
        				</a>
                    </div>
                    <div class="{if $Sections[menuItem].id eq $smarty.request.id}selected{/if}">{$Sections[menuItem].title|stripslashes}</div>
                    <div style="clear: both;"></div>
                    {if $Sections[menuItem].parent_id == 0 && $Sections[$smarty.section.menuItem.index_next].parent_id != 0}
                    	
                    {else}
                        </li>
                    {/if}
                    {if $Sections[menuItem].parent_id && ((!$smarty.section.menuItem.last && ($Sections[$smarty.section.menuItem.index_next].parent_id == 0)) || $smarty.section.menuItem.last)}
                        </li></ul></li>
                    {/if}
                {/section}
                </ul>
                {literal}
                <!-- <script>
                //    Sortable.create("sortables", {
                //        tree: true,
                //        onChange: function () {
                //            //alert(1);
                //        },
                //        onUpdate: function () {
                //            new Ajax.Request("{/literal}{$fvConfig->get('dir_web_root')}sections/reorder/{literal}", {
                //                parameters: Sortable.serialize("sortables")
                //            });
                //        }
                //    });
                //</script> -->
                {/literal}
                <div class="operation">
                    <a href="{$fvConfig->get('dir_web_root')}sections/" onclick="go('{$fvConfig->get('dir_web_root')}sections/'); return false;" class="add">добавить</a>
                </div>                
            </div>
        </div>
    </td>
    <td class="spacer">&nbsp;</td>
    <td id="datapanel">
		<div class="form">
		    <H1>{if $Section->isNew()}Добавление раздела{else}Редактирование раздела '{$Section->title}'{/if}</H1>
		    <form method="post" action="/backend/sections/save/">
		    <fieldset>
		        <legend>Общая информация</legend>
		        <table class="form">
		        	<tr>
		        		<td style="width: 1px;"><label for="name">Название</label></td>
		        		<td><input type="text" id="title" name="mn[title]" value="{$Section->title|escape|stripslashes}"/></td>
		        	</tr> 
		        	<tr>
		        		<td><label for="discount">Скидка:</label></td>
		        		<td><input type="text" id="discount" name="mn[discount]" value="{$Section->discount|escape|stripslashes}"/></td>
		        	</tr>
		        	<tr>
		        		<td style="width: 1px;"><label for="name">Название (транслит)</label></td>
		        		<td><input type="text" id="translit_title" name="mn[translit_title]" value="{$Section->translit_title|escape|stripslashes}"/></td>
		        	</tr>
		        	<tr>
		        		<td><label for="page_parent_id">Родительский раздел</label></td>
		        		<td>{html_options name=mn[parent_id] id=parent_id options=$SectionsOptions selected=$Section->parent_id}</td>
		        	</tr>
		        	{if !$Section->isNew() && $Section->parent_id == 0}
		        	<tr>
		        		<td><label for="filters">Фильтры</label></td>
		        		<td>
        					<div id="selectedFilters" class="selectedList">
        						<span id="selectedFiltersList" style="font-style: italic;">
        							{foreach item=selectedFilter from=$selectedFilters name=filterList}
        								{$selectedFilter->title}{if !$smarty.foreach.filterList.last},{/if}
        							{foreachelse}
        								не обрано
        							{/foreach}
        							</span>&nbsp;<span>[<a href="javascript:void(0);" id="selectFilters">обрати</a>] *</span>
        					</div>
        					<input type="hidden" id="filters" name="mn[filters]" value='{$Section->filters|stripslashes}'>
        				</td>
        			</tr>
        			{/if}
		        </table>
		    </fieldset> 
		    <div class="buttonpanel">
		        <input type="submit" name="save" value="Сохранить" class="button">
		    </div>
		    <input type="hidden" name="id" id="id" value="{$Section->getPk()}" />
		    </form>
		</div>
    </td>
  </tr>
</table>
{literal}
<script>
    function moveLeftPanel (e) {
        if ($('leftpanel').getDimensions().width > 100) {
            $('leftpanel').morph('width: 20px;');
            $('leftPanelHeader').update("");
            $('leftpaneldata').hide();
            $('collapse').src = '{/literal}{$fvConfig->get('dir_web_root')}img/expand.gif{literal}';
        } else {
            $('leftpanel').morph('width: 300px;');
            $('collapse').src = '{/literal}{$fvConfig->get('dir_web_root')}img/collapse.gif{literal}';
            setTimeout("$('leftPanelHeader').update('Список страниц')", 1000);
            setTimeout("$('leftpaneldata').show()", 1000);
        }
    }

    $('selectFilters').observe('click', function () {
    	window.getFilterWindow().show($F('filters'));	 
	});
	
    $('hidePanel').observe('click', moveLeftPanel);

    new MaskedInput('#discount', '9?9', {placeholder:" "});
</script>
{/literal}